package pt.ist.meic.pava;

import java.util.ArrayList;

import javassist.CtClass;
import javassist.CtMethod;



/**
 * 
 * @author Antonio Massingue
 * @author Joao Matos
 * @author Nuno Santos
 * 
 * This Exception should be thrown when a 
 * method required by a trait is not 
 * implemented by the composing class
 * 
 */
public class RequiredTraitMethodsException extends Exception {

	
	
	
	/**
	 * The Serial Version Id
	 */
	private static final long serialVersionUID = 1232733434426739046L;
	
	
	
	/**
	 * The annotated class
	 */
	private CtClass ctClass;
	
	
	
	/**
	 * A list containing the required methods of a trait
	 */
	private ArrayList<CtMethod> requiredMethodsList;
	
	
	
	
	
	
	
	
	/**
	 * Default Constructor
	 */
	public RequiredTraitMethodsException() {
		super();
		this.requiredMethodsList = new ArrayList<CtMethod>();
	}

	/**
	 * Overloaded Constructor
	 * @param aClass - the class involved on the throwing of this exception
	 */
	public RequiredTraitMethodsException(CtClass aCtClass,ArrayList<CtMethod> someRequiredMethodsList){
		super();
		this.ctClass = aCtClass;
		this.requiredMethodsList = someRequiredMethodsList;
	}
	
	
	
	
	
	
	
	
	/**
	 * This method prints the detailed message of this exception
	 */
	public void printRequiredTraitMethodsException() {
		String output="{";
		for (CtMethod required : requiredMethodsList){
			output+= required.getName()+"\n";
		}
		output+="}\n";
		System.err.println("The "+output+" of the Trait "+this.ctClass.getName()+" is required");
	}

	
	
	
	
	
	
	
	/**
	 * @return the annotated class
	 */
	public CtClass getCtClass() {
		return ctClass;
	}

	/**
	 * @param ctClass The annotated class
	 */
	public void setCtClass(CtClass ctClass) {
		this.ctClass = ctClass;
	}
	
	
	
	
	
	
	 
}
